<template>
	<!-- 我的车辆 -->
	<view class="bindCar">
			<view @click="navigateTo(v.carNum)" class="bindCarBox" v-for="v in tableData" :key="v.id">
				<view class="content">
					<image src="../../static/logo.png" mode=""></image>
					<view class="defails">
						<view class="xinXi">
							<view>{{v.carNum}}</view>
							<view class="carDetali">
								{{v.carType.carType}}{{v.model}}·{{v.carColor}}
							</view>
						</view>
						<view :class="v.person.state=='审核中'?'status':''">
							{{v.person.state=='审核中'?'未绑定':community+v.regionParking.regionName+v.regionParking.region.name}}
						</view>
					</view>
				</view>
			</view>

		<!-- 	<navigator url="./carDetail/carDetail" hover-class="navigator-hover">
			<view class="bindCarBox">
				<view class="content">
					<image src="../../static/logo.png" mode=""></image>
					<view class="defails">
						<view class="xinXi">
							<view>浙B·N6688</view>
							<view class="carDetali">
								宝马X5·白色
							</view>
						</view>
						<view class="status">
							未绑定
						</view>
					</view>
				</view>
			</view>
		</navigator> -->

		<!-- <navigator url="./carDetail/carDetail" hover-class="navigator-hover">
			<view class="bindCarBox">
				<view class="content">
					<image src="../../static/logo.png" mode=""></image>
					<view class="defails">
						<view class="xinXi">
							<view>浙B·N6688</view>
							<view class="carDetali">
								宝马X5·白色
							</view>
						</view>
						<view class="">
							南航碧桂园小区地下停车场B区09号
						</view>
					</view>
				</view>
			</view>
		</navigator> -->

		<!-- 添加 -->
		<navigator url="./addCar/addCar" hover-class="navigator-hover">
			<button type="default">+ 添加车辆</button>
		</navigator>
	</view>
</template>

<script>
	import {
		http
	} from '../../utils/http.js'
	export default {
		data() {
			return {
				serialNo: '',
				community:'',
				tableData: []
			}
		},
		methods: {
		navigateTo(v){
			uni.navigateTo({
				url:'./carDetail/carDetail?carNum='+v
			})
		}
		},
		onLoad() {
			try {
				const list = uni.getStorageSync('list');
				if (list) {
					this.serialNo = list.serialNo
					this.community=list.community
				}
				http({
						url: '/car/list',
						params: {
							page: 1,
							limit: 10000,
							serialNo: this.serialNo
						}
					})
					.then(({
						data
					}) => {
						console.log(data)
						this.tableData = data
					})
			} catch (e) {
				// error
			}
		}
	}
</script>

<style lang="less" scoped>
	.bindCar {
		margin: 60rpx 30rpx 0 30rpx;

		button {
			width: 680rpx;
			height: 80rpx;
			font-size: 36rpx;
			padding: 0;
			line-height: 80rpx;
			background: #006fff;
			color: white;
			margin-top: 80rpx;
		}

		.bindCarBox {
			box-shadow: 0px 0px 10rpx rgba(0, 0, 0, 0.3);
			border-radius: 4rpx;
			padding-left: 32rpx;
			padding-right: 64rpx;
			margin-bottom: 32rpx;
			display: flex;
			justify-content: space-between;
			height: 160rpx;

			.content {
				width: 100%;
				display: flex;
				align-items: center;

				image {
					width: 70rpx;
					height: 70rpx;
					border-radius: 50%;
					vertical-align: middle;
				}

				.defails {
					flex: 1;
					margin-left: 30rpx;

					.xinXi {
						display: flex;
						justify-content: space-between;
						align-items: center;
						font-size: 32rpx;
						margin-bottom: 20rpx;
					}

					view:nth-child(2) {
						font-size: 26rpx;
						color: #989898;
					}
				}
			}

			.carDetali {
				font-size: 32rpx;
				color: #989898;
				margin: 0;
			}

			.status {
				height: 44rpx;
				width: 130rpx;
				background: #d4f6e3;
				color: #20d26e;
				border-radius: 4px;
				text-align: center;
				font-size: 26rpx;
				line-height: 44rpx;
			}
		}
	}
</style>
